package com.wandian.weather.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wandian.weather.R;
import com.wandian.weather.bean.TianqiWeather30Bean;

import java.util.List;

public class WarningAdapter extends BaseQuickAdapter<TianqiWeather30Bean.UptempBean.DataBeanX, BaseViewHolder> {

    public WarningAdapter(int layoutResId, @Nullable List<TianqiWeather30Bean.UptempBean.DataBeanX> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TianqiWeather30Bean.UptempBean.DataBeanX item) {
        String bTime = item.getCdate().getStart_date();
        String eTime = item.getCdate().getEnd_date();
        helper.setText(R.id.tv_date, bTime+"~"+eTime);

        String lTemp = item.getLtemp()+"°";
        String hTemp = item.getHtemp()+"°";
        helper.setText(R.id.tv_temp1, lTemp);
        helper.setText(R.id.tv_temp2, hTemp);
        helper.setImageResource(R.id.img_temp, R.drawable.img_weather_temp_up);
        helper.setText(R.id.tv_warning_or_cooling, "升温幅度");

        float low_t = Float.parseFloat(item.getLtemp());
        float up_t = Float.parseFloat(item.getHtemp());

        helper.setText(R.id.tv_w_c_temp, (up_t - low_t)+"°");
    }
}
